﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.BasicData.PaymentTerms;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.BasicData.Controllers
{
    [RemoteService]
    [Route("api/v1/payment-terms")]
    public class PaymentTermController : BasicDataController
    {
        private IPaymentTermAppService _appService;

        public PaymentTermController(IPaymentTermAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<PaymentTermDto> GetAsync(Guid id)
        {
            return await _appService.GetAsync(id);
        }

        [HttpGet]
        public async Task<PagedResultDto<PaymentTermDto>> GetAsync(PaymentTermPagedResultRequestDto filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpPost]
        public async Task<PaymentTermDto> CreateAsync(PaymentTermCreateDto input)
        {
            return await _appService.CreateAsync(input);
        }

        [HttpPut]
        public async Task<PaymentTermDto> UpdateAsync(PaymentTermUpdateDto input)
        {
            return await _appService.UpdateAsync(input);
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }
    }
}
